package o;

import android.content.Context;
import android.content.IntentFilter;
import android.text.TextUtils;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.downloadengine.api.SplitTask;
import com.huawei.appgallery.downloadengine.impl.CdnServerInfo;
import com.huawei.appgallery.downloadengine.impl.FileWriter;
import com.huawei.appgallery.downloadengine.impl.SplitDownloadThreadInfo;
import com.huawei.hms.aaid.constant.AaidIdConstant;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.secure.android.common.intent.SafeIntent;
import com.huawei.updatesdk.service.otaupdate.UpdateKey;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Future;
import o.ah.g;
import o.bno.d;

class bnw implements bnx {
    private boolean ʻ = false;
    private volatile boolean ʼ = true;
    private volatile boolean ʽ = false;
    private bnv ˊ;
    private List<String> ˊॱ = new ArrayList();
    private SplitTask ˋ;
    private Object ˋॱ = new byte[0];
    private int ˎ = 0;
    private boolean ˏ = false;
    private bnj ˏॱ = null;
    private bnj ͺ = null;
    private SessionDownloadTask ॱ;
    private List<String> ॱˊ = new ArrayList();
    private List<bnu> ॱˋ = new CopyOnWriteArrayList();
    private boolean ॱˎ = false;
    private boolean ॱॱ = false;
    private boolean ॱᐝ = false;
    private Future<?> ᐝ = null;

    static class b {
        String ˋ = "";
        int ˎ = -1;
        boolean ˏ = false;
        Exception ॱ = null;

        b() {
        }
    }

    public bnw(bnv o_bnv, SplitTask splitTask) {
        this.ˊ = o_bnv;
        this.ॱ = o_bnv.ˋ();
        this.ˋ = splitTask;
        this.ˋ.ˊॱ(this.ॱ.ˊˊ());
        this.ˋ.ˊ(this.ॱ);
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void ॱॱ() throws o.bnj {
        /*
        r6 = this;
        r5 = 2;
        r4 = 0;
        r0 = o.bnc.ˎ;
        r1 = "HiAppDownload";
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r3 = "one splitTask download begin, packageName=";
        r2 = r2.append(r3);
        r3 = r6.ˋ;
        r3 = r3.ˎˎ();
        r2 = r2.append(r3);
        r3 = ", fileType=";
        r2 = r2.append(r3);
        r3 = r6.ˋ;
        r3 = r3.ᐝॱ();
        r2 = r2.append(r3);
        r2 = r2.toString();
        r0.ˋ(r1, r2);
        r6.ˏ = r4;
        r0 = 0;
        r6.ˏॱ = r0;
        r6.ˎ = r4;
        r0 = r6.ˋ;
        r0 = r0.ʾ();
        r1 = 1;
        if (r0 != r1) goto L_0x0093;
    L_0x0042:
        r0 = r6.ᐝ();
        if (r0 == 0) goto L_0x0053;
    L_0x0048:
        r0 = r6.ˏ;
        if (r0 != 0) goto L_0x009f;
    L_0x004c:
        r0 = r6.ˏॱ;
        if (r0 == 0) goto L_0x009f;
    L_0x0050:
        r0 = r6.ˏॱ;
        throw r0;
    L_0x0053:
        r0 = r6.ˏˏ();
        if (r0 == 0) goto L_0x008a;
    L_0x0059:
        r6.ˍ();
        r0 = r6.ˋ;
        r0.ˋ(r4);
        r0 = r6.ˋ;
        r0.ॱ(r5);
        r0 = r6.ˋ;
        r1 = r6.ˋ;
        r1 = r1.ᐝ();
        r0.ˏॱ(r1);
        r0 = r6.ˋ;
        r1 = r6.ˋ;
        r2 = r1.ʼ();
        r0.ˎ(r2);
        r0 = r6.ˋ;
        r1 = r6.ˋ;
        r1 = r1.ॱॱ();
        r0.ˋॱ(r1);
        r6.ˏॱ();
    L_0x008a:
        r6.ॱʻ();
        r0 = r6.ͺॱ();
        if (r0 == 0) goto L_0x0048;
    L_0x0093:
        r0 = r6.ˋ;
        r0 = r0.ʾ();
        if (r0 != r5) goto L_0x0048;
    L_0x009b:
        r6.ᐝ();
        goto L_0x0048;
    L_0x009f:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.bnw.ॱॱ():void");
    }

    private boolean ᐝ() throws bnj {
        ॱˎ();
        if (this.ˋ.ʿ() != 3) {
            ˎ(ͺ());
            if (this.ˏ) {
                return true;
            }
            if (ˏˏ()) {
                return false;
            }
            ॱʻ();
            if (!ͺॱ()) {
                return false;
            }
            if (ˑ()) {
                this.ˋ.ˋ(2);
                ˎ(true);
                if (this.ˏ) {
                    return true;
                }
                if (ˏˏ()) {
                    return false;
                }
                ॱʻ();
                if (!ͺॱ()) {
                    return false;
                }
            }
        }
        if (ˊॱ()) {
            ᐝॱ();
            if (this.ˏ) {
                return true;
            }
        }
        return false;
    }

    private void ˏॱ() {
        long j = 0;
        long j2 = 0;
        for (SplitTask splitTask : this.ॱ.ᐝˊ()) {
            j += splitTask.ˈ();
            j2 = splitTask.ʼॱ() + j2;
        }
        int i = (int) (((((double) j) * 1.0d) / ((double) j2)) * 100.0d);
        SessionDownloadTask sessionDownloadTask = this.ॱ;
        if (i > 100) {
            i = 100;
        }
        sessionDownloadTask.ʽ(i);
    }

    private boolean ͺ() {
        return this.ˋ.ʿ() != 1;
    }

    private boolean ˊॱ() {
        return this.ˋ.ʿ() == 3 || bnl.ˏ().ॱˊ().ॱ();
    }

    public void ʽ() {
        this.ʼ = false;
        if (this.ᐝ != null) {
            this.ᐝ.cancel(true);
        }
        ˋॱ();
    }

    public boolean ʻ() {
        return this.ॱˎ;
    }

    private void ˋॱ() {
        for (bnu o_bnu : this.ॱˋ) {
            o_bnu.ˋ();
            if (o_bnu.ˏ() != null) {
                o_bnu.ˏ().cancel(true);
            }
        }
    }

    private void ॱˊ() {
        long j = 0;
        for (SplitDownloadThreadInfo ʽ : this.ˋ.ˎ()) {
            j = ʽ.ʽ() + j;
        }
        this.ˋ.ˊ(j);
    }

    public void ˎ() {
        ॱˊ();
        this.ˊ.ॱ(false);
    }

    public void ॱ() {
        ॱˊ();
        this.ˊ.ॱ(true);
        ॱʽ();
        ʻॱ();
    }

    public void ˊ(bnj o_bnj) {
        if (this.ͺ == null) {
            this.ͺ = o_bnj;
        }
        ˋॱ();
        ʻॱ();
    }

    private void ʻॱ() {
        synchronized (this.ˋॱ) {
            this.ˋॱ.notifyAll();
        }
    }

    public boolean ˋ() {
        return this.ʽ;
    }

    public int ˊ() {
        return this.ˎ;
    }

    public String ˏ() {
        return null;
    }

    private void ॱˎ() {
        if (this.ˋ.ʿ() <= 0) {
            if (ˊ(this.ˋ.ॱˋ())) {
                this.ˋ.ˋ(2);
            } else {
                this.ˋ.ˋ(1);
            }
        }
        if (this.ˋ.ʿ() != 3) {
            ॱᐝ();
            bnc.ˎ.ˋ("HiAppDownload", "initDownloadPolicy :" + this.ˋ.ʿ());
        } else if (!bnl.ˏ().ॱˊ().ॱ() && !TextUtils.isEmpty(bnl.ˏ().ॱˊ().ˊ())) {
            this.ˋ.ˋ(2);
        }
    }

    private void ॱᐝ() {
        if ((bnl.ˏ().ᐝ() || this.ॱ.ˎˏ()) && this.ˋ.ʿ() == 1 && !TextUtils.isEmpty(bnl.ˏ().ॱˊ().ˊ())) {
            this.ˋ.ˋ(2);
        }
    }

    private void ᐝॱ() throws bnj {
        if (this.ˋ.ʿ() != 3) {
            this.ˋ.ˏॱ(ˏ(this.ˋ.ॱˋ(), bnl.ˏ().ॱˊ().ˏ()));
            this.ˋ.ˋ(3);
        }
        this.ʽ = true;
        try {
            ˎ(true);
            this.ʽ = false;
        } catch (Throwable th) {
            this.ʽ = false;
        }
    }

    public static String ˏ(String str, String str2) {
        try {
            URI uri = new URI(str);
            URI uri2 = new URI("https", null, str2, 443, uri.getPath(), uri.getQuery(), uri.getFragment());
            bnc.ˎ.ˋ("HiAppDownload", "update url with direct ip");
            str = uri2.toString();
        } catch (URISyntaxException e) {
        }
        return str;
    }

    private void ॱˋ() {
        bny.ˋ();
        bny.ॱॱ();
        bny.ʽ();
        this.ˋ.ˊ();
        this.ˋ.ॱ();
    }

    private void ˎ(boolean z) throws bnj {
        bnj e;
        int i = 0;
        this.ॱॱ = false;
        this.ˎ++;
        bnc.ˎ.ˋ("HiAppDownload", "doDownloadOnce begin:" + this.ॱ.ˊˊ() + ", roundCount=" + this.ˎ);
        this.ͺ = null;
        this.ˋ.b_(null);
        this.ˋ.ˏ(ˈ());
        int size;
        try {
            ˎˏ();
            ˏˎ();
            ˋˋ();
            ॱˋ();
            ˏ(z);
            ˋᐝ();
            size = this.ˊॱ.size();
            this.ॱᐝ = false;
            while (i < size) {
                String str = (String) this.ˊॱ.get(i);
                if (i == size - 1) {
                    this.ॱᐝ = true;
                }
                ˋ(str);
                i++;
                if (this.ˏ) {
                    return;
                }
            }
        } catch (bnj e2) {
            bnc.ˎ.ˊ("HiAppDownload", "doDownloadWithOneServer exception, errorCode:" + e2.ˊ());
            this.ˏॱ = e2;
            if (ˎ(e2)) {
                bni.ˊ(e2.ˋ(), this.ॱ, this.ˋ);
                i++;
            } else if (e2.ˊ() == 125) {
                bni.ˊ(e2.ˋ(), this.ॱ, this.ˋ);
                if (i != size - 1) {
                    i++;
                    bnc.ˎ.ˋ("HiAppDownload", "doDownloadOnce: cdn server changed");
                }
            } else {
                throw e2;
            }
        } catch (bnj e22) {
            this.ˏॱ = e22;
            if (bno.ॱ(e22)) {
                throw e22;
            }
            bnc.ˎ.ˊ("HiAppDownload", "doDownloadOnce exception, errorCode:" + e22.ˊ() + ", errorMessage:" + e22.ˏ());
            bni.ˊ(e22.ˋ(), this.ॱ, this.ˋ);
        } catch (Throwable th) {
            String ˎ = bny.ˎ(th);
            bnc.ˎ.ˊ("HiAppDownload", "doDownloadOnce exception,  errorMessage:" + th.toString() + "\n" + ˎ);
            e22 = new bnj(111, ˎ);
            bni.ˊ(e22.ˋ(), this.ॱ, this.ˋ);
            this.ˏॱ = e22;
        }
    }

    private boolean ˈ() {
        boolean z = true;
        try {
            int intExtra = new SafeIntent(bnl.ˏ().ॱ().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"))).getIntExtra(UpdateKey.STATUS, 1);
            if (!(intExtra == 2 || intExtra == 5)) {
                z = false;
            }
        } catch (SecurityException e) {
            bnc.ˎ.ˊ("HiAppDownload", "register battery changed broadcast exception,e: " + e.toString());
        }
        bnc.ˎ.ˋ("HiAppDownload", "is charging:" + z);
        return z;
    }

    private void ˋ(String str) throws bnj {
        boolean z = true;
        bnc.ˎ.ˋ("HiAppDownload", "doDownloadWithOneServer start");
        this.ͺ = null;
        this.ˋ.b_(str);
        ˎˎ();
        ˋˊ();
        ॱʻ();
        ˌ();
        ˊˋ();
        if (ˉ()) {
            ʽॱ();
            ʾ();
            this.ˏ = true;
            bnc.ˎ.ˋ("HiAppDownload", "doDownloadOnce succeed!");
        } else if (this.ͺ != null) {
            if (this.ͺ.ˊ() == 106 || this.ͺ.ˊ() == 122 || this.ͺ.ˊ() == 118 || this.ͺ.ˊ() == 127) {
                bnl.ˏ().ˋ(true);
            }
            if (this.ͺ.ˊ() == 122 || this.ͺ.ˊ() == 118 || this.ͺ.ˊ() == 127 || this.ͺ.ˊ() == 126) {
                if (this.ˋ.ˈ() <= 0) {
                    z = false;
                }
                this.ॱॱ = z;
                ˍ();
            }
            throw this.ͺ;
        }
    }

    private boolean ˎ(bnj o_bnj) {
        return bno.ˎ(o_bnj.ˊ()) || 109 == o_bnj.ˊ();
    }

    private String ʼॱ() {
        String str;
        String absolutePath = bnl.ˏ().ॱ().getFilesDir().getAbsolutePath();
        if (TextUtils.isEmpty(this.ˋ.ˊॱ())) {
            str = this.ˋ.ˎˎ() + "." + System.currentTimeMillis() + "_" + this.ˋ.ˊˋ() + ".apk";
        } else {
            str = this.ˋ.ˊॱ() + ".apk";
        }
        return absolutePath + File.separator + str;
    }

    private void ˋ(File file) {
        if (!file.setReadable(true, false)) {
            bnc.ˎ.ˊ("HiAppDownload", "can not set readable to apk");
        }
    }

    private int ˋ(File file, String str) {
        int ˎ;
        int i = 1;
        bnc.ˎ.ˋ("HiAppDownload", "begin smartMerge");
        try {
            ˎ = new bnz(new File(this.ˋ.ˊˊ()).getAbsolutePath(), this.ˋ.ॱॱ()).ˎ(str, file.getAbsolutePath());
        } catch (Throwable th) {
            bnc.ˎ.ˏ("HiAppDownload", "smartMerge exception:" + th.toString());
            Map hashMap = new HashMap();
            hashMap.put("errorCode", String.valueOf(111));
            hashMap.put("errorMessage", th.toString());
            bni.ˊ(hashMap, this.ॱ, this.ˋ);
            ˎ = 1;
        }
        if (!ˊ(116)) {
            i = ˎ;
        }
        bnc.ˎ.ˋ("HiAppDownload", "end smartMerge : result=" + i);
        return i;
    }

    private File ˏ(File file) throws bnj {
        String ˏ = dnw.ˏ(this.ˋ.ˎˎ(), bnl.ˏ().ॱ());
        if (ˏ == null) {
            bnc.ˎ.ˏ("HiAppDownload", "the apk is uninstalled: " + this.ॱ.ʿ());
            ˍ();
            throw new bnj(117, "merge failed as app has been uninstalled");
        }
        ॱʻ();
        File file2 = new File(file.getAbsolutePath() + ".apk");
        int ˋ = ˋ(file2, ˏ);
        if (!this.ʼ) {
            if (ˋ == 0 && !file2.delete()) {
                bnc.ˎ.ˊ("HiAppDownload", "delete merged file failed");
            }
            ॱʻ();
        }
        if (ˋ == 0) {
            return file2;
        }
        bnc.ˎ.ˊ("HiAppDownload", "smart merge failed:" + ˋ);
        ˏ = "smart merge failed " + ("[mergeErrorCode=" + ˋ + ", package=" + this.ˋ.ˎˎ() + ", diffSha256=" + this.ˋ.ˏॱ() + ", url=" + this.ˋ.ͺ() + "]");
        if (!file2.delete()) {
            bnc.ˎ.ˊ("HiAppDownload", "delete merged file failed");
        }
        ˍ();
        throw new bnj(116, ˏ);
    }

    private void ʾ() throws bnj {
        String ˊˊ;
        Object obj;
        int i;
        bnc.ˎ.ˋ("HiAppDownload", "begin processDownloadedTempFile");
        String str = "processDownloadedTempFile failed";
        File file = new File(this.ˋ.ˊˊ());
        if (file.exists()) {
            String str2;
            if (this.ˋ.ʾ() == 1) {
                bnc.ˎ.ˋ("HiAppDownload", "currentDiffPolicy is DL_POLICY_DIFF, FileName=" + file.getName());
                if (!"apk".equalsIgnoreCase(dnw.ˏ(file.getName()))) {
                    file = ˏ(file);
                }
            }
            ˊˊ = this.ˋ.ˊˊ();
            if (!this.ॱ.ꜟ()) {
                ˊˊ = ʼॱ();
                File file2 = new File(ˊˊ);
                if (file.renameTo(file2)) {
                    ˋ(file2);
                } else {
                    ˊˊ = file.getAbsolutePath();
                    ˋ(file);
                    str2 = ˊˊ;
                    this.ˋ.ॱ(str2);
                    if (this.ˋ.ʾ() == 1) {
                        bny.ˊ(this.ˋ.ˊˊ());
                    }
                    obj = 1;
                    ˊˊ = str;
                    i = 111;
                }
            }
            str2 = ˊˊ;
            this.ˋ.ॱ(str2);
            if (this.ˋ.ʾ() == 1) {
                bny.ˊ(this.ˋ.ˊˊ());
            }
            obj = 1;
            ˊˊ = str;
            i = 111;
        } else {
            bnc.ˎ.ˊ("HiAppDownload", "Downloaded file not exist:" + this.ˋ.ˎˎ());
            i = g.ॱˍ;
            ˊˊ = "Downloaded file not exist when process file ";
            obj = null;
        }
        bnc.ˎ.ˋ("HiAppDownload", "end processDownloadedTempFile");
        if (obj == null) {
            ˍ();
            throw new bnj(i, ˊˊ);
        }
    }

    private void ʽॱ() throws bnj {
        Closeable fileWriter;
        boolean z;
        String str;
        int i;
        Throwable e;
        boolean z2 = true;
        ॱʻ();
        bnc.ˎ.ˋ("HiAppDownload", "begin checkDownloadedFile :" + this.ˋ.ˎˎ());
        Closeable closeable = null;
        String str2 = "";
        try {
            fileWriter = new FileWriter(this.ˋ.ˊˊ(), "r");
            try {
                String str3;
                if (fileWriter.length() != this.ˋ.ʼॱ()) {
                    str3 = "checkDownloadedFile error: file length wrong " + (" downloadSize= " + fileWriter.length() + ˊˊ());
                    z = false;
                } else if (ʿ()) {
                    bnc.ˎ.ˋ("HiAppDownload", "checkDownloadedFile succeed");
                    str3 = str2;
                    z = true;
                } else {
                    StringBuilder append = new StringBuilder().append("checkDownloadedFile error : file hash error.  isSmart=");
                    if (this.ˋ.ʾ() == 1) {
                        z = true;
                    } else {
                        z = false;
                    }
                    str2 = append.append(z).append(", currentHash=").append(this.ˋ.ʽॱ()).append(ˊˊ()).toString();
                    bnl.ˏ().ˋ(true);
                    str3 = str2;
                    z = false;
                }
                bny.ˎ(fileWriter);
                str = str3;
                i = 118;
            } catch (IOException e2) {
                e = e2;
                closeable = fileWriter;
                try {
                    bnc.ˎ.ˊ("HiAppDownload", "checkDownloadedFile IOException:", e);
                    str2 = e.getMessage();
                    bny.ˎ(closeable);
                    i = 123;
                    str = str2;
                    z = false;
                    if (z) {
                        bnc.ˎ.ˊ("HiAppDownload", "end checkDownloadedFile failed");
                        if (this.ˋ.ˈ() <= 0) {
                            z2 = false;
                        }
                        this.ॱॱ = z2;
                        ˍ();
                        throw new bnj(i, str);
                    }
                } catch (Throwable th) {
                    e = th;
                    fileWriter = closeable;
                    bny.ˎ(fileWriter);
                    throw e;
                }
            } catch (Throwable th2) {
                e = th2;
                bny.ˎ(fileWriter);
                throw e;
            }
        } catch (IOException e3) {
            e = e3;
            bnc.ˎ.ˊ("HiAppDownload", "checkDownloadedFile IOException:", e);
            str2 = e.getMessage();
            bny.ˎ(closeable);
            i = 123;
            str = str2;
            z = false;
            if (z) {
                bnc.ˎ.ˊ("HiAppDownload", "end checkDownloadedFile failed");
                if (this.ˋ.ˈ() <= 0) {
                    z2 = false;
                }
                this.ॱॱ = z2;
                ˍ();
                throw new bnj(i, str);
            }
        } catch (Throwable th3) {
            e = th3;
            fileWriter = null;
            bny.ˎ(fileWriter);
            throw e;
        }
        if (z) {
            bnc.ˎ.ˊ("HiAppDownload", "end checkDownloadedFile failed");
            if (this.ˋ.ˈ() <= 0) {
                z2 = false;
            }
            this.ॱॱ = z2;
            ˍ();
            throw new bnj(i, str);
        }
    }

    private boolean ʿ() {
        Object ʽॱ = this.ˋ.ʽॱ();
        if (TextUtils.isEmpty(ʽॱ)) {
            bnc.ˎ.ˏ("HiAppDownload", "checkDownloadedFile warning: file sha256 is null");
        } else if (!ʽॱ.equalsIgnoreCase(dnw.ˎ(this.ˋ.ˊˊ(), AaidIdConstant.SIGNATURE_SHA256))) {
            bnc.ˎ.ˊ("HiAppDownload", "file sha256 check failed");
            return false;
        } else if (ˊ(118)) {
            return false;
        } else {
            bnc.ˎ.ˋ("HiAppDownload", "file sha256 check succeed");
        }
        return true;
    }

    private String ˊˊ() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(" package=").append(this.ˋ.ˎˎ()).append(", storeSize=").append(this.ˋ.ʼॱ());
        for (bnu o_bnu : this.ॱˋ) {
            stringBuilder.append(" [threadDownloadInfo start=").append(o_bnu.ˊ().ʻ()).append(", end=").append(o_bnu.ˊ().ॱॱ()).append(", finished=").append(o_bnu.ˊ().ʽ()).append(", totalRead=").append(o_bnu.ᐝ).append(", totalWrite=").append(o_bnu.ʽ).append(", lengthCheckedBeforeDownload=").append(o_bnu.ʼ).append(o_bnu.ˊ().ͺ()).append(", serverIp=").append(o_bnu.ˎ).append(", lastUrl=").append(o_bnu.ॱ).append("] ");
        }
        return stringBuilder.toString();
    }

    public SplitTask ʼ() {
        return this.ˋ;
    }

    private boolean ˉ() {
        for (bnu ˎ : this.ॱˋ) {
            if (!ˎ.ˎ()) {
                return false;
            }
        }
        return true;
    }

    private void ˊˋ() {
        try {
            bnt.ˋ().ˋ(this.ˋ);
        } catch (Exception e) {
            bnc.ˎ.ˊ("HiAppDownload", "updateSplitTask exception:" + e.getMessage());
        }
    }

    private void ˋˊ() {
        synchronized (this.ˋॱ) {
            while (!ˊᐝ() && this.ʼ) {
                try {
                    this.ˋॱ.wait(400);
                } catch (InterruptedException e) {
                    bnc.ˎ.ˋ("HiAppDownload", "waitAllDownloadThreadsDone interrupted");
                }
            }
        }
        bnc.ˎ.ˋ("HiAppDownload", "waitAllDownloadThreadsDone finished");
    }

    private boolean ˊᐝ() {
        for (bnu ॱ : this.ॱˋ) {
            if (!ॱ.ॱ()) {
                return false;
            }
        }
        return true;
    }

    private void ˌ() {
        List arrayList = new ArrayList();
        for (bnu o_bnu : this.ॱˋ) {
            if (!TextUtils.isEmpty(o_bnu.ˏ)) {
                CdnServerInfo cdnServerInfo = new CdnServerInfo();
                cdnServerInfo.ॱ(o_bnu.ˏ);
                cdnServerInfo.ˊ(o_bnu.ˎ);
                arrayList.add(cdnServerInfo);
            }
        }
        if (arrayList.size() == 0) {
            ˎ("[]");
            return;
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("[");
        for (int i = 0; i < arrayList.size(); i++) {
            if (arrayList.get(i) != null) {
                try {
                    stringBuilder.append(((CdnServerInfo) arrayList.get(i)).toJson());
                    stringBuilder.append(",");
                } catch (IllegalAccessException e) {
                    bnc.ˎ.ˊ("HiAppDownload", "setCdnServerInfo IllegalAccessException");
                }
            }
        }
        int length = stringBuilder.length();
        if (length > 0 && stringBuilder.charAt(length - 1) == ',') {
            stringBuilder.delete(length - 1, length);
        }
        stringBuilder.append("]");
        ˎ(stringBuilder.toString());
    }

    private void ˎˎ() throws bnj {
        ॱʻ();
        this.ॱˋ.clear();
        this.ॱˎ = true;
        for (SplitDownloadThreadInfo splitDownloadThreadInfo : this.ˋ.ˎ()) {
            boolean z;
            if (splitDownloadThreadInfo.ʻ() + splitDownloadThreadInfo.ʽ() > splitDownloadThreadInfo.ॱॱ()) {
                bnc.ˎ.ˋ("HiAppDownload", "one thread already download finished before, ignore");
            } else {
                bnu o_bnu = new bnu(this.ˋ, splitDownloadThreadInfo, this);
                this.ॱˋ.add(o_bnu);
                o_bnu.ˏ(bnl.ˏ().ˊॱ().submit(o_bnu));
                bnc.ˎ.ˋ("HiAppDownload", "summit thread task, start=" + splitDownloadThreadInfo.ʻ() + " end=" + splitDownloadThreadInfo.ॱॱ() + " finished=" + splitDownloadThreadInfo.ʽ());
                o_bnu.ˊ(this.ॱᐝ);
            }
            if (this.ॱˎ && splitDownloadThreadInfo.ʽ() == 0) {
                z = true;
            } else {
                z = false;
            }
            this.ॱˎ = z;
        }
    }

    private void ˋᐝ() throws bnj {
        bnc.ˎ.ˋ("HiAppDownload", "begin initDownloadThreadInfo");
        ॱʻ();
        List ˎ = this.ˋ.ˎ();
        ॱ(ˎ);
        if (ˎ.size() == 0) {
            long ʼॱ = this.ˋ.ʼॱ();
            int ˎ2 = bno.ˎ(ʼॱ);
            for (int i = 0; i < ˎ2; i++) {
                long j;
                long j2 = ʼॱ / ((long) ˎ2);
                long j3 = j2 * ((long) i);
                if (i == ˎ2 - 1) {
                    j = ʼॱ - 1;
                } else {
                    j = (j2 + j3) - 1;
                }
                ˎ.add(new SplitDownloadThreadInfo(this.ˋ.ˉ(), this.ˋ.ˊˋ(), j3, j));
            }
        }
    }

    private void ॱ(List<SplitDownloadThreadInfo> list) {
        if (list != null && !list.isEmpty()) {
            Object obj;
            for (SplitDownloadThreadInfo splitDownloadThreadInfo : list) {
                if (splitDownloadThreadInfo.ʻ() < this.ˋ.ʼॱ()) {
                    if (splitDownloadThreadInfo.ॱॱ() >= this.ˋ.ʼॱ()) {
                    }
                }
                obj = null;
            }
            int i = 1;
            if (obj == null) {
                list.clear();
                ˍ();
                bnc.ˎ.ˋ("HiAppDownload", "range is wrong ,reset");
            }
        }
    }

    private void ˍ() {
        bnc.ˎ.ˋ("HiAppDownload", "SplitTaskDownloader.doClear");
        bny.ˊ(this.ˋ.ˊˊ());
        this.ˋ.ˊ(0);
        bnt.ˋ().ॱ(this.ॱ.ʾ(), this.ˋ.ˊˋ());
        this.ˋ.ˎ().clear();
        ˏॱ();
    }

    private void ˋˋ() throws bnj {
        Context ॱ = bnl.ˏ().ॱ();
        if (ॱ != null) {
            try {
                if (!doo.ˊ(ॱ)) {
                    bnc.ˎ.ˋ("HiAppDownload", "download interrupted as no active network");
                    throw new bnj(129, "no active network");
                }
            } catch (SecurityException e) {
                bnc.ˎ.ˊ("HiAppDownload", "checkNet exception");
            }
        }
    }

    private static boolean ˊ(String str) {
        if (str == null) {
            return false;
        }
        return str.toLowerCase(Locale.getDefault()).startsWith("https");
    }

    private boolean ˑ() {
        if (this.ˋ.ʿ() != 1 || TextUtils.isEmpty(bnl.ˏ().ॱˊ().ˊ())) {
            return false;
        }
        return true;
    }

    private boolean ͺॱ() {
        Context ॱ = bnl.ˏ().ॱ();
        boolean z = doo.ॱॱ(ॱ) && !doo.ᐝ(ॱ);
        if (!z && this.ॱॱ) {
            return false;
        }
        return true;
    }

    private boolean ˏˏ() {
        if (this.ˋ.ʾ() == 1 && this.ˏॱ != null && this.ˏॱ.ˊ() == 116) {
            return true;
        }
        return false;
    }

    private void ˎˏ() throws bnj {
        String str = "";
        if (TextUtils.isEmpty(this.ˋ.ॱˋ())) {
            str = "current url is null";
            bnc.ˎ.ˊ("HiAppDownload", "before download, check task failed:" + str);
            throw new bnj(100, str);
        }
        try {
            URL url = new URL(this.ˋ.ॱˋ());
            if (this.ˋ.ʼॱ() <= 0) {
                str = "size is wrong ";
                String str2 = "[size=" + this.ˋ.ʼ() + ", diffSize=" + this.ˋ.ʻ() + "]";
                bnc.ˎ.ˊ("HiAppDownload", "before download, check task failed:" + str + str2);
                throw new bnj(100, str + str2);
            }
        } catch (MalformedURLException e) {
            str = "url is wrong : " + this.ˋ.ॱˋ();
            bnc.ˎ.ˊ("HiAppDownload", "before download, check task failed:" + str);
            throw new bnj(100, str);
        }
    }

    private boolean ˏˎ() throws bnj {
        bnc.ˎ.ˋ("HiAppDownload", "begin checkLocalBeforeDownload");
        bny.ˊ(this.ॱ);
        ˊ(bnl.ˏ().ॱ(), this.ˋ, this.ॱ.ꜟ(), this.ˋ.ʾ() == 1);
        return true;
    }

    private String ॱ(SplitTask splitTask, boolean z, boolean z2) {
        String str;
        if (z) {
            str = splitTask.ˎˎ() + "_" + splitTask.ˊˋ();
            if (!TextUtils.isEmpty(splitTask.ˊॱ())) {
                str = splitTask.ˊॱ();
            }
        } else {
            str = splitTask.ˎˎ() + "." + System.currentTimeMillis();
        }
        if (z2) {
            str = str + ".vcdiff";
        } else {
            str = str + ".apk";
        }
        bnc.ˎ.ˋ("HiAppDownload", "downloadFileName=" + str);
        return str;
    }

    public boolean ˊ(Context context, SplitTask splitTask, boolean z, boolean z2) {
        String absolutePath = context.getFilesDir().getAbsolutePath();
        if (z) {
            absolutePath = absolutePath + File.separator + "splits" + File.separator + splitTask.ˉ();
        } else {
            absolutePath = absolutePath + File.separator + "tmp";
        }
        File file = new File(absolutePath);
        if ((!file.exists() || !file.isDirectory()) && !file.mkdirs()) {
            return false;
        }
        if (!TextUtils.isEmpty(splitTask.ˊˊ()) && new File(splitTask.ˊˊ()).exists()) {
            return true;
        }
        File file2 = new File(file, ॱ(splitTask, z, z2));
        if (!file2.exists() || file2.delete()) {
            try {
                if (file2.createNewFile()) {
                    splitTask.ͺ(file2.getAbsolutePath());
                    splitTask.ˎ().clear();
                    splitTask.ˊ(0);
                    bnt.ˋ().ॱ(this.ॱ.ʾ(), splitTask.ˊˋ());
                    return true;
                }
                bnc.ˎ.ˊ("HiAppDownload", "create new file failed!");
                return false;
            } catch (Throwable e) {
                bnc.ˎ.ˊ("HiAppDownload", "create " + file2.getAbsolutePath() + ", failed!", e);
            }
        } else {
            bnc.ˎ.ˊ("HiAppDownload", "file delete failed!");
            return false;
        }
    }

    private void ॱʻ() throws bnj {
        if (this.ʼ && !this.ˊ.ˎ()) {
            ʽ();
        }
        if (!this.ʼ) {
            throw new bnj(DnsConfig.MAX_CACHE_ENTRIES, "download interrupted");
        }
    }

    private void ˋ(boolean z, List<String> list) {
        Object ˊ;
        if (z) {
            if (ˊ(this.ˋ.ॱˋ())) {
                list.add(this.ˋ.ॱˋ());
            }
            if (!this.ʽ) {
                ˊ = bnl.ˏ().ॱˊ().ˊ();
                if (!TextUtils.isEmpty(ˊ)) {
                    CharSequence ˏ = bno.ˏ(this.ˋ.ॱˋ(), ˊ);
                    if (!TextUtils.isEmpty(ˏ) && !list.contains(ˏ)) {
                        list.add(ˏ);
                        return;
                    }
                    return;
                }
                return;
            }
            return;
        }
        if (!ˊ(this.ˋ.ॱˋ())) {
            list.add(this.ˋ.ॱˋ());
        }
        ˊ = bnl.ˏ().ॱˊ().ˎ();
        if (!TextUtils.isEmpty(ˊ)) {
            String ˏ2 = bno.ˏ(this.ˋ.ॱˋ(), ˊ);
            if (!list.contains(ˏ2)) {
                list.add(ˏ2);
            }
        }
    }

    private d ॱ(String str, String str2, Map<String, List<String>> map) {
        d dVar = new d();
        dVar.ˋ = str;
        dVar.ˎ = false;
        dVar.ॱॱ = str2;
        if (this.ʽ) {
            dVar.ॱॱ = bnl.ˏ().ॱˊ().ʻ();
        } else if (map.containsKey(str2)) {
            dVar.ˏ = (List) map.get(str2);
            this.ʻ = true;
        }
        return dVar;
    }

    private void ˊ(fvb o_fvb, b bVar) {
        if (o_fvb != null) {
            int ˊ = o_fvb.ˊ();
            bVar.ˎ = ˊ;
            if (ˊ == 302 || ˊ == 301) {
                bVar.ˋ = o_fvb.ˋ("location");
                if (TextUtils.isEmpty(bVar.ˋ)) {
                    bVar.ॱ = new Exception("bad dispatch location:null");
                    return;
                }
                if (this.ʽ) {
                    bVar.ˋ = bVar.ˋ.replaceFirst("/" + bnl.ˏ().ॱˊ().ʻ(), "");
                }
                try {
                    URL url = new URL(bVar.ˋ);
                    bVar.ˏ = true;
                } catch (MalformedURLException e) {
                    bnc.ˎ.ˊ("HiAppDownload", "doWithConnectResult MalformedURLException happened");
                    bVar.ॱ = new Exception("bad dispatch location");
                }
            } else if (ˊ != 200) {
                bVar.ॱ = new Exception("bad dispatch response:" + ˊ);
            } else if (this.ʽ) {
                bVar.ॱ = new Exception("bad dispatch directIPMode response: 200");
            } else {
                bVar.ˏ = true;
            }
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private o.bnw.b ˏ(java.lang.String r12) throws o.bnj {
        /*
        r11 = this;
        r0 = 0;
        r2 = new o.bnw$b;
        r2.<init>();
        r3 = o.bno.ˋ(r12);
        r11.ʻ = r0;
        r4 = new java.util.LinkedHashMap;
        r4.<init>();
    L_0x0011:
        r11.ॱʻ();
        r1 = 0;
        r5 = r11.ॱ(r12, r3, r4);	 Catch:{ Exception -> 0x00c9 }
        r5 = o.bno.ˎ(r11, r5);	 Catch:{ Exception -> 0x00c9 }
        if (r5 != 0) goto L_0x0023;
    L_0x001f:
        o.bny.ˎ(r1);
    L_0x0022:
        return r2;
    L_0x0023:
        r6 = r5.ˊ();	 Catch:{ Exception -> 0x00c9 }
        if (r6 == 0) goto L_0x0034;
    L_0x0029:
        r1 = r5.ˏ();	 Catch:{ Exception -> 0x00c9 }
        r11.ˊ(r1, r2);	 Catch:{ Exception -> 0x00c9 }
        o.bny.ˎ(r1);
        goto L_0x0022;
    L_0x0034:
        r5 = r5.ˎ();	 Catch:{ Exception -> 0x00c9 }
        if (r5 != 0) goto L_0x003e;
    L_0x003a:
        o.bny.ˎ(r1);
        goto L_0x0022;
    L_0x003e:
        r6 = o.bnc.ˎ;	 Catch:{ Exception -> 0x00c9 }
        r7 = "HiAppDownload";
        r8 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x00c9 }
        r8.<init>();	 Catch:{ Exception -> 0x00c9 }
        r9 = "tryConnect exception:";
        r8 = r8.append(r9);	 Catch:{ Exception -> 0x00c9 }
        r9 = r5.getMessage();	 Catch:{ Exception -> 0x00c9 }
        r9 = o.bno.ˏ(r9);	 Catch:{ Exception -> 0x00c9 }
        r8 = r8.append(r9);	 Catch:{ Exception -> 0x00c9 }
        r8 = r8.toString();	 Catch:{ Exception -> 0x00c9 }
        r6.ˊ(r7, r8);	 Catch:{ Exception -> 0x00c9 }
        r2.ॱ = r5;	 Catch:{ Exception -> 0x00c9 }
        r6 = 0;
        r6 = o.dmv.ˏ(r6, r5);	 Catch:{ Exception -> 0x00c9 }
        r7 = o.bno.ˋ(r5);	 Catch:{ Exception -> 0x00c9 }
        if (r7 == 0) goto L_0x0076;
    L_0x006d:
        r0 = r0 + 1;
    L_0x006f:
        o.bny.ˎ(r1);
        r1 = 3;
        if (r0 < r1) goto L_0x0011;
    L_0x0075:
        goto L_0x0022;
    L_0x0076:
        if (r6 <= 0) goto L_0x00f8;
    L_0x0078:
        r7 = r11.ʻ;	 Catch:{ Exception -> 0x00c9 }
        if (r7 == 0) goto L_0x0080;
    L_0x007c:
        o.bny.ˎ(r1);
        goto L_0x0022;
    L_0x0080:
        r7 = new java.net.URL;	 Catch:{ Exception -> 0x00c9 }
        r7.<init>(r12);	 Catch:{ Exception -> 0x00c9 }
        r7 = r7.getHost();	 Catch:{ Exception -> 0x00c9 }
        r8 = o.bni.ॱ(r7);	 Catch:{ Exception -> 0x00c9 }
        if (r8 == 0) goto L_0x0093;
    L_0x008f:
        o.bny.ˎ(r1);
        goto L_0x0022;
    L_0x0093:
        r5 = o.dmv.ˎ(r7, r5, r6);	 Catch:{ Exception -> 0x00c9 }
        r8 = r5.size();	 Catch:{ Exception -> 0x00c9 }
        if (r8 <= 0) goto L_0x00f3;
    L_0x009d:
        r4.put(r7, r5);	 Catch:{ Exception -> 0x00c9 }
        r7 = o.bnc.ˎ;	 Catch:{ Exception -> 0x00c9 }
        r8 = "HiAppDownload";
        r9 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x00c9 }
        r9.<init>();	 Catch:{ Exception -> 0x00c9 }
        r10 = "download ok3 dnsKeeper error code:";
        r9 = r9.append(r10);	 Catch:{ Exception -> 0x00c9 }
        r6 = r9.append(r6);	 Catch:{ Exception -> 0x00c9 }
        r9 = " dnsKeeperIps=";
        r6 = r6.append(r9);	 Catch:{ Exception -> 0x00c9 }
        r5 = r5.toString();	 Catch:{ Exception -> 0x00c9 }
        r5 = r6.append(r5);	 Catch:{ Exception -> 0x00c9 }
        r5 = r5.toString();	 Catch:{ Exception -> 0x00c9 }
        r7.ˋ(r8, r5);	 Catch:{ Exception -> 0x00c9 }
        goto L_0x006f;
    L_0x00c9:
        r0 = move-exception;
        r3 = o.bnc.ˎ;	 Catch:{ all -> 0x00fd }
        r4 = "HiAppDownload";
        r5 = new java.lang.StringBuilder;	 Catch:{ all -> 0x00fd }
        r5.<init>();	 Catch:{ all -> 0x00fd }
        r6 = "doDispatchByOneUrl:";
        r5 = r5.append(r6);	 Catch:{ all -> 0x00fd }
        r6 = r0.getMessage();	 Catch:{ all -> 0x00fd }
        r6 = o.bno.ˏ(r6);	 Catch:{ all -> 0x00fd }
        r5 = r5.append(r6);	 Catch:{ all -> 0x00fd }
        r5 = r5.toString();	 Catch:{ all -> 0x00fd }
        r3.ˊ(r4, r5);	 Catch:{ all -> 0x00fd }
        r2.ॱ = r0;	 Catch:{ all -> 0x00fd }
        o.bny.ˎ(r1);
        goto L_0x0022;
    L_0x00f3:
        o.bny.ˎ(r1);
        goto L_0x0022;
    L_0x00f8:
        o.bny.ˎ(r1);
        goto L_0x0022;
    L_0x00fd:
        r0 = move-exception;
        o.bny.ˎ(r1);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.bnw.ˏ(java.lang.String):o.bnw$b");
    }

    private void ॱ(String str) {
        this.ˊॱ.add(str);
        if (!this.ʽ) {
            List ˋ;
            String ͺ = bnl.ˏ().ͺ();
            if (TextUtils.isEmpty(ͺ)) {
                bnc.ˎ.ˋ("HiAppDownload", "configure download params from backupDomainInfo, cdnBackupDomain");
                ˋ = bnl.ˏ().ॱˊ().ˋ();
            } else {
                bnc.ˎ.ˋ("HiAppDownload", "configure download params from backupDomainInfo, backupDomainInfo=" + ͺ);
                ˋ = Arrays.asList(ͺ.split(","));
            }
            int i = 0;
            while (i < ˋ.size() && i < 2) {
                bnc.ˎ.ˋ("HiAppDownload", "configureDownloadUrl cdnBackupDomainList" + i + " = " + ((String) ˋ.get(i)));
                ͺ = bno.ˊ(str, (String) ˋ.get(i));
                if (!this.ˊॱ.contains(ͺ)) {
                    this.ˊॱ.add(ͺ);
                }
                i++;
            }
        }
    }

    private void ˏ(boolean z) throws bnj {
        bnc.ˎ.ˋ("HiAppDownload", "begin doDispatch, useHttps: " + z + "  package:" + this.ॱ.ˊˊ());
        List<String> arrayList = new ArrayList();
        ˋ(z, (List) arrayList);
        this.ˋ.ˊ(z ? 2 : 1);
        this.ॱˊ.clear();
        this.ˊॱ.clear();
        int i = 0;
        for (String str : arrayList) {
            bnc.ˎ.ˋ("HiAppDownload", "doDispatch try one url : " + str);
            b ˏ = ˏ(str);
            ॱʻ();
            if (ˏ.ˏ) {
                if (ˊ(119)) {
                    break;
                }
                i = ˏ.ˎ;
                bnc.ˎ.ˋ("HiAppDownload", "dispatch responseCode=" + i);
                if (i == 302 || i == 301) {
                    ॱ(ˏ.ˋ);
                    bnc.ˎ.ˋ("HiAppDownload", "doDispatch succeed, package: " + this.ॱ.ˊˊ() + ", url=" + ˏ.ˋ);
                    return;
                } else if (i == 200) {
                    ॱ(str);
                    bnc.ˎ.ˋ("HiAppDownload", "doDispatch succeed, no redirect, package: " + this.ॱ.ˊˊ());
                    return;
                }
            } else if (ˏ.ॱ != null) {
                bnc.ˎ.ˊ("HiAppDownload", " dispatch once failed: " + bno.ˏ(ˏ.ॱ.getMessage()));
                this.ॱˊ.add("url=" + str + " , exception=" + bno.ˏ(ˏ.ॱ.getMessage()));
            }
        }
        ˊ(null);
        bnc.ˎ.ˊ("HiAppDownload", "doDispatch failed, package: " + this.ॱ.ˊˊ());
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("dispatch failed [package = ").append(this.ॱ.ˊˊ()).append(", errorInfo=");
        for (String str2 : this.ॱˊ) {
            stringBuffer.append(str2).append(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
        }
        stringBuffer.append(" ]");
        bnj o_bnj = new bnj(119, stringBuffer.toString());
        if (i > 0) {
            o_bnj.ˋ().put("httpResponseCode", String.valueOf(i));
        }
        throw o_bnj;
    }

    private boolean ˊ(int i) {
        if (bny.ˎ(i)) {
            int ˏ = bns.ॱ().ˏ();
            if (ˏ <= 0 || ˏ == this.ˎ) {
                return true;
            }
        }
        return false;
    }

    public void ˊ(Future<?> future) {
        this.ᐝ = future;
    }

    public void ˎ(String str) {
        this.ॱ.ˊॱ(str);
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void ॱʽ() {
        /*
        r14 = this;
        r0 = o.bnl.ˏ();
        r0 = r0.ॱᐝ();
        if (r0 != 0) goto L_0x0014;
    L_0x000a:
        r0 = o.bnc.ˎ;
        r1 = "HiAppDownload";
        r2 = "doDynamicDownload disabled";
        r0.ˋ(r1, r2);
    L_0x0013:
        return;
    L_0x0014:
        r10 = r14.ˋ;
        monitor-enter(r10);
        r0 = r14.ˋ;	 Catch:{ all -> 0x009d }
        r0 = r0.ˎ();	 Catch:{ all -> 0x009d }
        r1 = o.bno.ˊ;	 Catch:{ all -> 0x009d }
        r4 = (long) r1;	 Catch:{ all -> 0x009d }
        r1 = 0;
        r6 = r0.iterator();	 Catch:{ all -> 0x009d }
    L_0x0025:
        r0 = r6.hasNext();	 Catch:{ all -> 0x009d }
        if (r0 == 0) goto L_0x0065;
    L_0x002b:
        r0 = r6.next();	 Catch:{ all -> 0x009d }
        r0 = (com.huawei.appgallery.downloadengine.impl.SplitDownloadThreadInfo) r0;	 Catch:{ all -> 0x009d }
        r2 = r0.ʼ();	 Catch:{ all -> 0x009d }
        r8 = 0;
        r2 = (r2 > r8 ? 1 : (r2 == r8 ? 0 : -1));
        if (r2 <= 0) goto L_0x015c;
    L_0x003b:
        r2 = java.lang.System.currentTimeMillis();	 Catch:{ all -> 0x009d }
        r8 = r0.ᐝ();	 Catch:{ all -> 0x009d }
        r2 = r2 - r8;
        r8 = r0.ॱॱ();	 Catch:{ all -> 0x009d }
        r12 = r0.ʻ();	 Catch:{ all -> 0x009d }
        r8 = r8 - r12;
        r12 = r0.ʽ();	 Catch:{ all -> 0x009d }
        r8 = r8 - r12;
        r2 = r2 * r8;
        r2 = (double) r2;	 Catch:{ all -> 0x009d }
        r8 = r0.ʼ();	 Catch:{ all -> 0x009d }
        r8 = (double) r8;	 Catch:{ all -> 0x009d }
        r12 = 4611686018427387904; // 0x4000000000000000 float:0.0 double:2.0;
        r8 = r8 * r12;
        r2 = r2 / r8;
        r2 = (long) r2;	 Catch:{ all -> 0x009d }
        r7 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r7 <= 0) goto L_0x015c;
    L_0x0062:
        r1 = r0;
        r4 = r2;
        goto L_0x0025;
    L_0x0065:
        if (r1 == 0) goto L_0x0159;
    L_0x0067:
        r8 = r1.ॱॱ();	 Catch:{ all -> 0x009d }
        r2 = r1.ॱॱ();	 Catch:{ all -> 0x009d }
        r6 = r1.ʻ();	 Catch:{ all -> 0x009d }
        r2 = r2 - r6;
        r6 = r1.ʽ();	 Catch:{ all -> 0x009d }
        r2 = r2 - r6;
        r6 = 2;
        r2 = r2 / r6;
        r6 = r1.ॱॱ();	 Catch:{ all -> 0x009d }
        r6 = r6 - r2;
        r2 = r1.ʻ();	 Catch:{ all -> 0x009d }
        r0 = (r6 > r2 ? 1 : (r6 == r2 ? 0 : -1));
        if (r0 <= 0) goto L_0x0091;
    L_0x0089:
        r2 = r1.ॱॱ();	 Catch:{ all -> 0x009d }
        r0 = (r6 > r2 ? 1 : (r6 == r2 ? 0 : -1));
        if (r0 < 0) goto L_0x00a0;
    L_0x0091:
        r0 = o.bnc.ˎ;	 Catch:{ all -> 0x009d }
        r1 = "HiAppDownload";
        r2 = "bad new end, skip doDynamicDownload";
        r0.ˏ(r1, r2);	 Catch:{ all -> 0x009d }
        monitor-exit(r10);	 Catch:{ all -> 0x009d }
        goto L_0x0013;
    L_0x009d:
        r0 = move-exception;
        monitor-exit(r10);	 Catch:{ all -> 0x009d }
        throw r0;
    L_0x00a0:
        r0 = o.bnc.ˎ;	 Catch:{ all -> 0x009d }
        r2 = "HiAppDownload";
        r3 = new java.lang.StringBuilder;	 Catch:{ all -> 0x009d }
        r3.<init>();	 Catch:{ all -> 0x009d }
        r11 = "doDynamicDownload, update old threadInfo: start=";
        r3 = r3.append(r11);	 Catch:{ all -> 0x009d }
        r12 = r1.ʻ();	 Catch:{ all -> 0x009d }
        r3 = r3.append(r12);	 Catch:{ all -> 0x009d }
        r11 = ", end=";
        r3 = r3.append(r11);	 Catch:{ all -> 0x009d }
        r3 = r3.append(r6);	 Catch:{ all -> 0x009d }
        r11 = ", finished=";
        r3 = r3.append(r11);	 Catch:{ all -> 0x009d }
        r12 = r1.ʽ();	 Catch:{ all -> 0x009d }
        r3 = r3.append(r12);	 Catch:{ all -> 0x009d }
        r11 = ", timeSaved=";
        r3 = r3.append(r11);	 Catch:{ all -> 0x009d }
        r3 = r3.append(r4);	 Catch:{ all -> 0x009d }
        r3 = r3.toString();	 Catch:{ all -> 0x009d }
        r0.ˋ(r2, r3);	 Catch:{ all -> 0x009d }
        r1.ॱ(r6);	 Catch:{ all -> 0x009d }
        r0 = 1;
        r1.ˊ(r0);	 Catch:{ all -> 0x009d }
        r1 = new com.huawei.appgallery.downloadengine.impl.SplitDownloadThreadInfo;	 Catch:{ all -> 0x009d }
        r0 = r14.ॱ;	 Catch:{ all -> 0x009d }
        r2 = r0.ʾ();	 Catch:{ all -> 0x009d }
        r0 = r14.ˋ;	 Catch:{ all -> 0x009d }
        r4 = r0.ˊˋ();	 Catch:{ all -> 0x009d }
        r12 = 1;
        r6 = r6 + r12;
        r1.<init>(r2, r4, r6, r8);	 Catch:{ all -> 0x009d }
        r0 = r14.ˋ;	 Catch:{ all -> 0x009d }
        r0 = r0.ˎ();	 Catch:{ all -> 0x009d }
        r0.add(r1);	 Catch:{ all -> 0x009d }
        r0 = new o.bnu;	 Catch:{ all -> 0x009d }
        r2 = r14.ˋ;	 Catch:{ all -> 0x009d }
        r0.<init>(r2, r1, r14);	 Catch:{ all -> 0x009d }
        r2 = r14.ॱˋ;	 Catch:{ all -> 0x009d }
        r2.add(r0);	 Catch:{ all -> 0x009d }
        r2 = o.bnl.ˏ();	 Catch:{ all -> 0x009d }
        r2 = r2.ˊॱ();	 Catch:{ all -> 0x009d }
        r2 = r2.submit(r0);	 Catch:{ all -> 0x009d }
        r0.ˏ(r2);	 Catch:{ all -> 0x009d }
        r0 = o.bnc.ˎ;	 Catch:{ all -> 0x009d }
        r2 = "HiAppDownload";
        r3 = new java.lang.StringBuilder;	 Catch:{ all -> 0x009d }
        r3.<init>();	 Catch:{ all -> 0x009d }
        r4 = "doDynamicDownload:summit thread task, start=";
        r3 = r3.append(r4);	 Catch:{ all -> 0x009d }
        r4 = r1.ʻ();	 Catch:{ all -> 0x009d }
        r3 = r3.append(r4);	 Catch:{ all -> 0x009d }
        r4 = " end=";
        r3 = r3.append(r4);	 Catch:{ all -> 0x009d }
        r4 = r1.ॱॱ();	 Catch:{ all -> 0x009d }
        r3 = r3.append(r4);	 Catch:{ all -> 0x009d }
        r4 = " finished=";
        r3 = r3.append(r4);	 Catch:{ all -> 0x009d }
        r4 = r1.ʽ();	 Catch:{ all -> 0x009d }
        r1 = r3.append(r4);	 Catch:{ all -> 0x009d }
        r1 = r1.toString();	 Catch:{ all -> 0x009d }
        r0.ˋ(r2, r1);	 Catch:{ all -> 0x009d }
    L_0x0159:
        monitor-exit(r10);	 Catch:{ all -> 0x009d }
        goto L_0x0013;
    L_0x015c:
        r0 = r1;
        r2 = r4;
        goto L_0x0062;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.bnw.ॱʽ():void");
    }
}
